Set C/C++ go-to fallback defaults between definition and declaration - #14681
Conversation
…nd implement tests
There was a problem hiding this comment.
Pull request overview
Adds reciprocal declaration/definition navigation fallbacks for C, C++, and CUDA C++.
Changes:
- Configures declaration and definition fallback commands.
- Adds unit coverage for all supported language defaults.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
Extension/package.json |
Adds language-specific navigation defaults. |
Extension/test/unit/gotoLocationDefaults.test.ts |
Verifies the defaults for C, C++, and CUDA C++. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
For the most part we avoid changing VS Code defaults for languages because they are more difficult for the average user to override. We have only approved very few changes to the default settings that negatively impact the experience. I don't think this is a change we want to take unless we get more feedback that confirms this is a widespread problem with the experience. I believe our language server is supposed to return the declaration when on the definition and vice versa already so I'd rather we fix any bugs in the language server itself than apply this policy for all users. |
|
Bob Brown (@bobbrow) My impression was that is a widespread problem. I recall the default fallback is find all references which is almost never what a user wants. I think these defaults are what users actually want for C/C++, but I haven't tried it out yet. I think there is one case where were return the declaration for the definition but not the other way around or something. I don't think there's a cpptools side bug. |
This PR improves C/C++ navigation defaults so definition and declaration commands fall back to each other automatically.
Linked issue
Fixes #14509
What changed
editor.gotoLocation.alternativeDefinitionCommand=editor.action.revealDeclarationeditor.gotoLocation.alternativeDeclarationCommand=editor.action.revealDefinition[c][cpp][cuda-cpp]Why
This provides smoother F12 behavior across declaration/definition contexts without requiring users to create custom keybindings by file extension.
Test coverage
package.jsonfor[c],[cpp], and[cuda-cpp]../node_modules/.bin/mocha.cmd dist/test/unit/gotoLocationDefaults.test.js --timeout 30000